package com.bbx.taxi.client.Fragment;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import com.baidu.location.BDLocation;
import com.bbx.androidapi.util.SharedPreUtil;
import com.bbx.androidapi.util.ToastUtil;
import com.bbx.api.sdk.model.passanger.Return.Elements;
import com.bbx.api.sdk.model.passanger.Return.OrderId;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.End;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Location;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Locations;
import com.bbx.api.sdk.model.passanger.Return.MyOrderList.Start;
import com.bbx.api.sdk.net.base.JsonBuild;
import com.bbx.api.sdk.net.passeger.conn.CodeNet;
import com.bbx.api.sdk.net.passeger.conn.OrderSubmitNet;
import com.bbx.taxi.client.Task.BaseAsyncTask;
import com.bbx.api.util.LogUtils;
import com.bbx.api.util.SharedPreEncryptUtil;
import com.bbx.taxi.client.MyApplication;
import com.bbx.taxi.client.Activity.ContactPersonActivity;
import com.bbx.taxi.client.Activity.LeaveMessageActivity;
import com.bbx.taxi.client.Activity.MainActivity.MyOnPageScrolledListener;
import com.bbx.taxi.client.Activity.PlaneActivity;
import com.bbx.taxi.client.Activity.MainActivity;
import com.bbx.taxi.client.Activity.MainActivity.OnMenuClickListener;
import com.bbx.taxi.client.Activity.Order.StartServiceActivity;
import com.bbx.taxi.client.Activity.login.LoginActivity.CodeTask;
import com.bbx.taxi.client.Activity.Address.EditAddressActivity;
import com.bbx.taxi.client.Activity.Base.BaseFragment;
import com.bbx.taxi.client.Bean.Value;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute;
import com.bbx.taxi.client.Bean.Attribute.MainAttribute.OnContentFillingListener;
import com.bbx.taxi.client.Bean.Extra.AddressMsg;
import com.bbx.taxi.client.Bean.Extra.ContactPersonMsg;
import com.bbx.taxi.client.Bean.Extra.MainMsg;
import com.bbx.taxi.client.DB.Util.DBcolumns;
import com.bbx.taxi.client.MyApplication.OnLocationResultListener;
import com.bbx.taxi.official.R;
import com.bbx.taxi.client.Task.MyLineTask;
import com.bbx.taxi.client.Task.MyLineTask.OnLineFinishListener;
import com.bbx.taxi.client.Util.ClickFilter;
import com.bbx.taxi.client.Util.DateFormat;
import com.bbx.taxi.client.Util.FormatUtil;
import com.bbx.taxi.client.Util.ToCity;
import com.bbx.taxi.client.widget.pop.CollecteAddressPop;
import com.bbx.taxi.client.widget.pop.CollecteAddressPop.OnAddressItemClickListener;
import com.bbx.taxi.client.widget.pop.DatePicker;
import com.bbx.taxi.client.widget.pop.DatePicker.OnConfirmListener;
import com.bbx.taxi.client.widget.pop.DatePicker.OnDateConfirmListener;
import com.bbx.taxi.client.widget.pop.DatePicker.OnDateScrollResultListener;
import com.bbx.taxi.client.widget.pop.DatePicker.OnPeopleScrollResultListener;
import com.example.mydatepicker.wheelview.WheelView;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

/**
 * 拼车出行
 */
public class CityCarFragment extends BaseFragment implements OnClickListener,OnLineFinishListener,
		OnMenuClickListener ,MyOnPageScrolledListener{
	private RelativeLayout timelayout;
	private RelativeLayout personlayout;
	// private RelativeLayout layout_plane;
	private RelativeLayout layout_convert;
	// private RelativeLayout layout_people;
	private RelativeLayout layout_start_address;
	private RelativeLayout layout_end_address;
	// private RelativeLayout layout_message;
	private LinearLayout layout_start_collecte, layout_end_collecte;
	private TextView tv_time;
	// private TextView tv_plane_numble;
	// private TextView tv_plane_time;
	private TextView tv_start_address;
	private TextView tv_end_address;
	public TextView tv_telephone;
	public TextView tv_no_incity;
	public ScrollView scrollview;
	public LinearLayout layout_tel;
	public TextView tv_city_tel;
	public ImageView iv_city_tel;
	// private TextView tv_people_number;
	// private TextView tv_message;
	// private ImageView iv__plane_delete;
	private Context mContext;
	private MyApplication mApplication;
	private MainActivity mainActivity;
	/** 主界面的信息临时存储 */
	private MainAttribute main;
	// 市内叫车电话
	public String xiadanTel = "";
	private boolean isCity = true;
	private boolean isInit=false;
	private boolean isLoadLine=true;

	/**
	 * 主界面内容填写监听
	 * 
	 */
	public interface OnTelInterfaceListener {
		/**
		 * 主界面内容填写监听方法
		 */
		public void onTelInterface(boolean isTel);
	};

	public OnTelInterfaceListener mOnTelInterfaceListener;

	public void setOnTelInterfaceListener(
			OnTelInterfaceListener hOnTelInterfaceListener) {
		mOnTelInterfaceListener = hOnTelInterfaceListener;
	}

	public void removeOnTelInterfaceListener(
			OnContentFillingListener hOnContentFillingListener) {
		mOnTelInterfaceListener = null;
	}

	public void onCreateView(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_citycar);
		mApplication = MyApplication.getInstance();
		mContext = mApplication.getApplicationContext();
		main = MainAttribute.getInstance();
		mainActivity=(MainActivity)getActivity();
		mainActivity.setMyOnPageScrolledListener(this);
		init();
		initView();
//		 mApplication.loctionCity="厦门市";
//		 onLocationResult();
	}

	private void init() {
		scrollview = (ScrollView) findViewById(R.id.scrollview);
		tv_time = (TextView) findViewById(R.id.tv_time);
		// tv_plane_numble = (TextView) findViewById(R.id.tv_plane_numble);
		// tv_plane_time = (TextView) findViewById(R.id.tv_plane_time);
		tv_start_address = (TextView) findViewById(R.id.tv_start_address);
		tv_end_address = (TextView) findViewById(R.id.tv_end_address);
		tv_telephone = (TextView) findViewById(R.id.tv_telephone);
		// tv_people_number = (TextView) findViewById(R.id.tv_people_number);
		// tv_message = (TextView) findViewById(R.id.tv_message);
		tv_no_incity = (TextView) findViewById(R.id.tv_no_incity);
		timelayout = (RelativeLayout) findViewById(R.id.timelayout);
		// layout_plane = (RelativeLayout) findViewById(R.id.layout_plane);
		personlayout = (RelativeLayout) findViewById(R.id.personlayout);
		layout_convert = (RelativeLayout) findViewById(R.id.layout_convert);
		// layout_people = (RelativeLayout) findViewById(R.id.layout_people);
		layout_start_address = (RelativeLayout) findViewById(R.id.layout_start_address);
		layout_end_address = (RelativeLayout) findViewById(R.id.layout_end_address);
		// layout_message = (RelativeLayout) findViewById(R.id.layout_message);
		layout_start_collecte = (LinearLayout) findViewById(R.id.layout_start_collecte);
		layout_end_collecte = (LinearLayout) findViewById(R.id.layout_end_collecte);
		// iv__plane_delete = (ImageView) findViewById(R.id.iv__plane_delete);
		layout_tel = (LinearLayout) findViewById(R.id.layout_tel);
		tv_city_tel = (TextView) findViewById(R.id.tv_city_tel);
		iv_city_tel = (ImageView) findViewById(R.id.iv_city_tel);
		timelayout.setOnClickListener(this);
		personlayout.setOnClickListener(this);
		layout_convert.setOnClickListener(this);
		// layout_people.setOnClickListener(this);
		layout_start_address.setOnClickListener(this);
		layout_end_address.setOnClickListener(this);
		// iv__plane_delete.setOnClickListener(this);
		// layout_message.setOnClickListener(this);
		layout_start_collecte.setOnClickListener(this);
		layout_end_collecte.setOnClickListener(this);
		iv_city_tel.setOnClickListener(this);
		MainActivity.setOnMenuClickListener(this);
		if(isInit){
			onLocationResult();
		}
	}

	public void initView() {
		main = MainAttribute.getInstance();
		mainActivity=(MainActivity)getActivity();
		mainActivity=(MainActivity)getActivity();
		if (main != null&&tv_time!=null) {
			// 时间
			tv_time.setText(main.getTime());
			// 出发地
			if (main.getStartName(isCity) != null) {
				tv_start_address.setText(main.getStartName(isCity));
			}
			// 目的地
			if (main.getEndName(isCity) != null) {
				tv_end_address.setText(main.getEndName(isCity));
			}
			// 姓名和电话
			if (main.getName() != null && main.getTel() != null
					&& !main.getTel().equals("")) {
				tv_telephone.setText((main.getName().equals("") ? mContext
						.getString(R.string.i) : main.getName())
						+ "-"
						+ FormatUtil.onFormatTelephone(main.getTel()));
			}
			// 人数
			// tv_people_number.setText(String.format(mContext.getString(R.string.num),
			// main.getCount()));
			// 留言
			// if (main.getMessage_PC()!=null) {
			// tv_message.setText(main.getMessage_PC());
			// }
			// else{
			// tv_message.setText("");
			// }
			// 有航班，取消點擊
			// if (main.getPlaneStatus() != 0) {
			// layout_end_address.setClickable(false);
			// timelayout.setClickable(false);
			// layout_plane.setVisibility(View.VISIBLE);
			// tv_plane_numble.setText(main.getPlaneNumble());
			// tv_plane_time.setText(main.getTime());
			// } else {
			// layout_plane.setVisibility(View.GONE);
			// }
		}
	}

	@Override
	public void onClick(View v) {
		if(!ClickFilter.filter())return;
		switch (v.getId()) {
		case R.id.timelayout:
			// DatePicker.getInstance(mContext).onShow(v, 1);
			// DatePicker.getInstance(mContext).setOnDateScrollResultListener(
			// new OnDateScrollResultListener() {
			// @Override
			// public void OnDateScrollResult(List<String> list,
			// WheelView wl_day, WheelView wl_hour, WheelView wl_min) {
			// switch (wl_day.getCurrentItem()) {
			// case 0:// 接班机
			// wl_hour.setCurrentItem(0, true);
			// wl_min.setCurrentItem(0, true);
			// break;
			// case 1://
			// wl_hour.setCurrentItem(1, true);
			// wl_min.setCurrentItem(1, true);
			// break;
			// case 2:// 今天，滑动到当前时间
			// long Time =
			// DateFormat.getTime()+20*60*1000;//加20分上去，是为了不让选择当前时间+20分以下的时间
			// Calendar mCalendar = Calendar.getInstance();
			// mCalendar.setTimeInMillis(Time);
			// int hour=mCalendar.get(Calendar.HOUR_OF_DAY);
			// int minute=mCalendar.get(Calendar.MINUTE);
			// if((wl_hour.getCurrentItem()-2)<=(hour)){
			// wl_hour.setCurrentItem(hour+2,true);
			// if((wl_min.getCurrentItem()-2)<=(minute)){
			// wl_min.setCurrentItem(minute+2,true);
			// }
			// }
			// break;
			// default:
			// if (wl_hour.getCurrentItem() == 0
			// || wl_hour.getCurrentItem() == 1) {
			// wl_hour.setCurrentItem(2, true);
			// }
			// if (wl_min.getCurrentItem() == 0
			// || wl_min.getCurrentItem() == 1) {
			// wl_min.setCurrentItem(2, true);
			// }
			// break;
			// }
			// }
			// });
			// DatePicker.getInstance(mContext).setOnDateConfirmListener(
			// new OnDateConfirmListener() {
			// @Override
			// public void onDateConfirm(List<String> list,
			// WheelView wl_day, WheelView wl_hour, WheelView wl_min) {
			// if(wl_day.getCurrentItem()==0||wl_day.getCurrentItem()==1){
			// main.setTime(list.get(wl_day.getCurrentItem()));
			// tv_time.setText(main.getTime());
			// if(wl_day.getCurrentItem()==0){
			// startActivityForResult(new Intent(mContext,PlaneActivity.class),
			// MainAttribute.REQUEST_CODE_PLANE);
			// }
			// return ;
			// }
			// main.setTime(DatePicker.getInstance(mContext).onTimeFormat(list.get(wl_day.getCurrentItem()),
			// wl_hour.getCurrentItem() - 2, wl_min.getCurrentItem() - 2));
			// tv_time.setText(main.getTime());
			// }
			// });
			DatePicker.getInstance(mContext).onShow(v, 2);
			DatePicker.getInstance(mContext).setOnDateScrollResultListener(
					new OnDateScrollResultListener() {
						@Override
						public void OnDateScrollResult(List<String> list,List<String> list_min,
								WheelView wl_day, WheelView wl_hour,
								WheelView wl_min) {
							switch (wl_day.getCurrentItem()) {
							case 0://
								wl_hour.setCurrentItem(0, true);
								wl_min.setCurrentItem(0, true);
								break;
							case 1:// 今天，滑动到当前时间
								long Time = DateFormat.getTime() + 20 * 60 * 1000;// 加20分上去，是为了不让选择当前时间+20分以下的时间
								Calendar mCalendar = Calendar.getInstance();
								mCalendar.setTimeInMillis(Time);
								int hour = mCalendar.get(Calendar.HOUR_OF_DAY);
								int minute = mCalendar.get(Calendar.MINUTE);
								if ((wl_hour.getCurrentItem() - 1) <= (hour)) {
									wl_hour.setCurrentItem(hour + 1, true);
									if (wl_min.getCurrentItem()==0||Integer.parseInt(list_min.get(wl_min.getCurrentItem() )) <= (minute)) {
										int index=0;
										for(int i=1;i<list_min.size();i++){
											int min=Integer.parseInt(list_min.get(i));
											if(minute==min){
												index=i;
												break;
											}else{
												if(minute>min&&(minute-min<5)){
													index=i+1;
													break;
												}
											}
										}
										wl_min.setCurrentItem(index, true);
									}
								}
								break;
							default:
								if (wl_hour.getCurrentItem() == 0) {
									wl_hour.setCurrentItem(1, true);
								}
								if (wl_min.getCurrentItem() == 0) {
									wl_min.setCurrentItem(1, true);
								}
								break;
							}
						}
					});
			DatePicker.getInstance(mContext).setOnDateConfirmListener(
					new OnDateConfirmListener() {
						@Override
						public void onDateConfirm(List<String> list,List<String> list_min,
								WheelView wl_day, WheelView wl_hour,
								WheelView wl_min,int estimate_time) {
							if (wl_day.getCurrentItem() == 0) {
								main.setTime(list.get(wl_day.getCurrentItem()));
								tv_time.setText(main.getTime());
								return;
							}
							main.setTime(DatePicker.getInstance(mContext)
									.onTimeFormat(
											list.get(wl_day.getCurrentItem()),
											wl_hour.getCurrentItem() - 1,
											Integer.parseInt(list_min.get(wl_min.getCurrentItem() ))));
							tv_time.setText(main.getTime());
						}
					});
			break;
		case R.id.layout_people:
			DatePicker.getInstance(mContext).onShowPeople(v, 4,
					mContext.getString(R.string.num_rule));
			DatePicker.getInstance(mContext).setOnConfirmListener(
					new OnConfirmListener() {
						@Override
						public void onConfirm(List<String> list,
								WheelView people) {
							main.setCount(people.getCurrentItem() + 1);
							// tv_people_number.setText(String.format(mContext.getString(R.string.num),
							// main.getCount()));
						}
					});
			break;
		case R.id.personlayout:
			personlayout.setClickable(false);
			startActivityForResult(
					new Intent(mContext, ContactPersonActivity.class)
							.putExtra(ContactPersonMsg.extra_contact_name,
									main.getName()).putExtra(
									ContactPersonMsg.extra_contact_phone,
									main.getTel()),
					MainAttribute.REQUEST_CODE_PERSON);
			break;
		case R.id.layout_start_address:
			layout_start_address.setClickable(false);
			if (MainActivity.isLocation) {
				startActivityForResult(
						new Intent(mContext, EditAddressActivity.class)
								.putExtra(AddressMsg.extra_editaddress,
										AddressMsg.ADDRESS_START_MAIN)
								.putExtra(AddressMsg.extra_incity,
										AddressMsg.INCITY)
								.putExtra(
							     AddressMsg.extra_cityopend,true),
						MainAttribute.REQUEST_CODE_START_ADDRESS);
			} else {
				layout_start_address.setClickable(true);
				ToastUtil.showToast(mContext, R.string.islocation_fail);
			}
			break;
		case R.id.layout_end_address:
			layout_end_address.setClickable(false);
			if (MainActivity.isLocation) {
				startActivityForResult(
						new Intent(mContext, EditAddressActivity.class)
								.putExtra(AddressMsg.extra_editaddress,
										AddressMsg.ADDRESS_END_MAIN).putExtra(
										AddressMsg.extra_incity,
										AddressMsg.INCITY),
						MainAttribute.REQUEST_CODE_END_ADDRESS);
			} else {
				layout_end_address.setClickable(true);
				ToastUtil.showToast(mContext, R.string.islocation_fail);
			}
			break;
		case R.id.layout_convert:
			main.onSwap(isCity);
			tv_start_address.setText(main.getStartName(isCity));
			tv_end_address.setText(main.getEndName(isCity));
			tv_end_address.setTextColor(mContext.getResources().getColor(
					R.color.black));
			break;
		case R.id.iv__plane_delete:
			// layout_plane.setVisibility(View.GONE);
			// layout_end_address.setClickable(true);
			// timelayout.setClickable(true);
			// main.setPlaneStatus(0);
			break;
		case R.id.layout_message:
			startActivityForResult(new Intent(mContext,
					LeaveMessageActivity.class).putExtra(MainMsg.extra_message,
					MainMsg.MESSAGE_MAIN_PC),
					MainAttribute.REQUEST_CODE_MESSAGE);
			break;
		case R.id.layout_start_collecte:
			CollecteAddressPop.getInstance(mContext).onShow(v);
			CollecteAddressPop.getInstance(mContext).setOnItemClickListener(
					new OnAddressItemClickListener() {
						@Override
						public void onItemClick(List<Map<String, String>> list,
								int position) {
							main.setStartName(
									list.get(position).get(
											DBcolumns.ADDRESS_NAME), isCity);
							main.setStartCity(
									list.get(position).get(
											DBcolumns.ADDRESS_CITY), isCity);
							main.setStartAddress(
									list.get(position).get(
											DBcolumns.ADDRESS_ADDRESS), isCity);
							main.setStartLongitude(
									Double.parseDouble(list.get(position).get(
											DBcolumns.ADDRESS_LONGITUDE)),
									isCity);
							main.setStartLatitude(
									Double.parseDouble(list.get(position).get(
											DBcolumns.ADDRESS_LATITUDE)),
									isCity);
							if (!main.getStartName(isCity).equals("")) {
								tv_start_address.setText(main
										.getStartName(isCity));
							}
						}
					});
			break;
		case R.id.layout_end_collecte:
			CollecteAddressPop.getInstance(mContext).onShow(v);
			CollecteAddressPop.getInstance(mContext).setOnItemClickListener(
					new OnAddressItemClickListener() {
						@Override
						public void onItemClick(List<Map<String, String>> list,
								int position) {
							main.setEndName(
									list.get(position).get(
											DBcolumns.ADDRESS_NAME), isCity);
							main.setEndCity(
									list.get(position).get(
											DBcolumns.ADDRESS_CITY), isCity);
							main.setEndAddress(
									list.get(position).get(
											DBcolumns.ADDRESS_ADDRESS), isCity);
							main.setEndLongitude(
									Double.parseDouble(list.get(position).get(
											DBcolumns.ADDRESS_LONGITUDE)),
									isCity);
							main.setEndLatitude(
									Double.parseDouble(list.get(position).get(
											DBcolumns.ADDRESS_LATITUDE)),
									isCity);
							if (!main.getEndName(isCity).equals("")) {
								tv_end_address.setText(main.getEndName(isCity));
							}
						}
					});
			break;
		case R.id.iv_city_tel:
			startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ xiadanTel)));
			break;

		}
	}

	public boolean onLocationResult() {
		boolean isError = false;
		mApplication = MyApplication.getInstance();
		if (tv_start_address != null)
			tv_start_address.setText(main.getStartName(isCity));
		String str_incity_type = SharedPreUtil.getStringValue(mContext,
				SharedPreEncryptUtil.list_incity_type, "");
		String str_incity_phone = SharedPreUtil.getStringValue(mContext,
				SharedPreEncryptUtil.list_incity_phone, "");
		String str_incity_cn = SharedPreUtil.getStringValue(mContext,
				SharedPreEncryptUtil.list_incity_cn, "");
		List<String> list_incity_type = Arrays.asList(str_incity_type
				.replace("[", "").replace("]", "").trim().split(","));
		List<String> list_incity_phone = Arrays.asList(str_incity_phone
				.replace("[", "").replace("]", "").trim().split(","));
		List<String> list_incity_cn = Arrays.asList(str_incity_cn
				.replace("[", "").replace("]", "").trim().split(","));
		if (scrollview != null && tv_no_incity != null && layout_tel != null&&mApplication.loctionCity!=null
				&&!mApplication.loctionCity.equals("")&&!mApplication.loctionCity.equals(mContext.getString(R.string.default_city))) {
			if (list_incity_cn != null&&list_incity_cn.size()>0&&!str_incity_cn.replace("[", "").replace("]", "").equals("")) {
				scrollview.setVisibility(View.GONE);
				tv_no_incity.setVisibility(View.VISIBLE);
				layout_tel.setVisibility(View.GONE);
				if (mOnTelInterfaceListener != null) {
					mOnTelInterfaceListener.onTelInterface(false);
				}
				for (int i = 0; i < list_incity_cn.size(); i++) {
					//去除市
					String str_city=list_incity_cn.get(i).trim();
					str_city=ToCity.getCityName(str_city);
					//定位城市去除市
					String str_location_city=mApplication.loctionCity.trim();
					str_location_city=ToCity.getCityName(str_location_city);
					
					// 定位城市是市内叫车
					if (str_city
							.equals(str_location_city)) {
						// app下单
						if (list_incity_type.get(i).trim()
								.equals(Value.CITY_APP)) {
							scrollview.setVisibility(View.VISIBLE);
							tv_no_incity.setVisibility(View.GONE);
							layout_tel.setVisibility(View.GONE);
							if (mOnTelInterfaceListener != null) {
								mOnTelInterfaceListener.onTelInterface(false);
							}
						}
						// 电话下单
						else if (list_incity_type.get(i).trim()
								.equals(Value.CITY_TEL)) {
							xiadanTel = list_incity_phone.get(i);
							tv_city_tel.setText(xiadanTel);
							scrollview.setVisibility(View.GONE);
							tv_no_incity.setVisibility(View.GONE);
							layout_tel.setVisibility(View.VISIBLE);
							if (mOnTelInterfaceListener != null) {
								mOnTelInterfaceListener.onTelInterface(true);
							}
						}
						break;
					}
				}

			} else {// 显示没有开通城市
				if(isLoadLine){
					MyLineTask.getInstance(mContext).setOnLineFinishListener(this);	
				}
				else{
					scrollview.setVisibility(View.GONE);
					tv_no_incity.setVisibility(View.VISIBLE);
					layout_tel.setVisibility(View.GONE);
					if (mOnTelInterfaceListener != null) {
						mOnTelInterfaceListener.onTelInterface(false);
					}
				}

			}
		} else {
			isInit=true;
			isError = true;
		}
		return isError;
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		switch (requestCode) {
		case MainAttribute.REQUEST_CODE_PERSON:// 电话
			personlayout.setClickable(true);
			if (data != null) {
				main.setTel(data.getStringExtra("telephone"));
				main.setName(data.getStringExtra("name"));
				if (main.getName() != null && main.getTel() != null
						&& !main.getName().equals("")
						&& !main.getTel().equals("")) {
					tv_telephone.setText(main.getName() + "-"
							+ FormatUtil.onFormatTelephone(main.getTel()));
				}
			}
			break;
		case MainAttribute.REQUEST_CODE_START_ADDRESS:// 出发地
			layout_start_address.setClickable(true);
			if (data != null) {
				main.setStartCity(
						data.getStringExtra(AddressMsg.extra_address_city),
						isCity);
				main.setStartAddress(
						data.getStringExtra(AddressMsg.extra_address_address),
						isCity);
				main.setStartLongitude(data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0), isCity);
				main.setStartLatitude(data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0), isCity);
				main.setStartName(
						data.getStringExtra(AddressMsg.extra_address_name),
						isCity);
				if (!main.getStartName(isCity).equals("")) {
					tv_start_address.setText(main.getStartName(isCity));
				}
			}
			break;
		case MainAttribute.REQUEST_CODE_END_ADDRESS:
			layout_end_address.setClickable(true);
			if (data != null) {
				main.setEndCity(
						data.getStringExtra(AddressMsg.extra_address_city),
						isCity);
				main.setEndAddress(
						data.getStringExtra(AddressMsg.extra_address_address),
						isCity);
				main.setEndLongitude(data.getDoubleExtra(
						AddressMsg.extra_address_longitude, 0), isCity);
				main.setEndLatitude(data.getDoubleExtra(
						AddressMsg.extra_address_latitude, 0), isCity);
				main.setEndName(
						data.getStringExtra(AddressMsg.extra_address_name),
						isCity);
				if (!main.getEndName(isCity).equals("")) {
					tv_end_address.setText(main.getEndName(isCity));
					tv_end_address.setTextColor(mContext.getResources()
							.getColor(R.color.black));
				}
				LogUtils.e("", data.getStringExtra(AddressMsg.extra_address_address));
			}
			break;
		case MainAttribute.REQUEST_CODE_PLANE:
			if (data != null) {
				// layout_plane.setVisibility(View.VISIBLE);
				// main.setPlaneStatus(data.getIntExtra("plane_status", 0));
				// main.setTime(data.getStringExtra("plane_time"));
				// main.setPlaneNumble(data.getStringExtra("plane_numble"));
				// main.setEndName(data.getStringExtra("plane_end_address"));
				// tv_plane_numble.setText(main.getPlaneNumble());
				// tv_plane_time.setText(main.getTime());
				// tv_time.setText(main.getTime());
				// initView();
			}
			break;
		case MainAttribute.REQUEST_CODE_MESSAGE:
			if (data != null) {
				main.setMessage_PC(data.getStringExtra("message"));
				initView();
			}
			break;
		}
		super.onActivityResult(requestCode, resultCode, data);
	}

	@Override
	public void OnMenuClick() {
		initView();
	}

	@Override
	public void onLineFinish(boolean isisSuccess) {
		if(isisSuccess){
		isLoadLine=false;
		onLocationResult();
		}else{
			MyLineTask.getInstance(mContext).setOnLineFinishListener(this);	
		}
	}

	@Override
	public void onPageScrolled(int viewid) {
		if(viewid==Value.VIEWID_SN){
			initView();
			onLocationResult();
		}
	}
}
